In this lecture, we'll look at the implementation of the
configuration data in our game. As you probably expected, we're using an unreal data table to import our game
configuration data. Except this time, we have 34 different
configuration data values. We have way more
than we've used in the past when we were
doing configuration data. Using our standard technique, we defined a struct to define
the structure of that data. We have a whole bunch
of fields here. Then we have a whole
bunch of UPROPERTY for each of those 34
different fields. We're also using a
ConfigurationDataActor. We saved the difficulty
because there are a number of different functions
that returned difficulty specific values, and we save a pointer to our configuration data row just as you've seen
me do in the past. Of course, I populate a UPROPERTY with my
Configuration Data Table. Then I have the standard stuff and then I have a whole
bunch of getters. In the implementation file for my ConfigurationDataActor,
on BeginPlay, I open the safe game
because remember, the saved game is
where I saved it, the difficulty from
the difficulty menu and I save that here. Then I retrieved that
ConfigurationDataRow and save that into my field. Many of these getters
just returned the value from the
ConfigurationDataRow. But some of them are
difficulty specific. Starting with MinSpawnDelay
for spawning teddy bears, depending on what
the difficulty is, I may be using the
EasyMinSpawnDelay, the MediumMinSpawnDelay
or the HardMinSpawnDelay. I always include a default. Just in case the difficulty
is something weird, I just say it's an easy game. So a number of my getters return difficulty
specific information. That's all hidden from whoever is calling the
GetMinSpawnDelay function. They don't have to care about what difficulty the game is. The ConfigurationDataActor
knows what difficulty the game is and returns the appropriate value based on the game difficulty and the data that's stored in the
ConfigurationDataRow. We have implementations for
all of the getters that are providing access to the configuration
data for the game. I'll just show you one
example of a class using the configuration
data, the BurgerPawn. On BeginPlay, gets in and saves a pointer to the
ConfigurationData object. Then, for example, if we're going to move, we set a MoveAmountPerSecond
variable to whatever the ConfigurationDataActor says is the
BurgerMoveAmountPerSecond. I only use the variable
here because I know I use it here and here and I didn't want to have to call
that function twice. This is one example of an actor using the
ConfigurationData, but the actors that need to
use the ConfigurationData, I'll use the same
pattern of getting, and saving a pointer to the
ConfigurationDataActor, and then accessing the
appropriate functions to use the ConfigurationData in that ConfigurationDataActor rather than using constants. To recap, in this lecture, we saw how we can use a
ConfigurationDataActor to provide ConfigurationData to the other objects
in the game. We also saw that as our
games get more complicated, we may end up with lots of
ConfigurationData values.